import {ElMessage} from "element-plus";

export function goTop(acceleration, time) {
    window.scrollTo(0,0)
}
export function goTo(x,y) {
    window.scrollTo(x,y)
}

export function numberFormat(number) {
    if(number<10000){
        return number
    }else{
        return Math.ceil(number/1000)/10+'w'
    }
}


export function  successMessage(str) {
    ElMessage.success({
        message: str,
        type: 'success',
        offset:100,
        showClose:true,
        center: true,
        duration:2000
    })
}
export function  errorMessage(str) {
    ElMessage.error({
        message: str,
        type: 'error',
        offset:100,
        showClose:true,
        center: true,
    })
}
export function getToken(){
    return localStorage.getItem("token")
}

export function rejectMessage(resp) {
    if(resp.data.code===401){
        errorMessage("无权限操作")
        return true
    }
    return false
}
export function autoDeleteToken(time) {
    setTimeout(()=>{
        localStorage.removeItem("token")
    },time)
}
export  function goToElement(refObject,otherHeight) {

   if(!otherHeight){
      otherHeight=0
   }
    window.scrollTo(0,refObject.value.offsetHeight+otherHeight)

}
